﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOFrameworks;
using FAQFrameworks;
using FooFun.DataElements.Dtos;

namespace FooFun.Web.Controls
{
    public class FixAnswerControl : DataElementControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ShowContent(NamedContent.Empty);
        }

        public override IDataElement DataElement
        {
            get
            {
                return base.DataElement;
            }
            set
            {
                base.DataElement = value;

                if (!base.DataElement.IsEmpty)
                {
                    // 没有终结的问题
                    if (!DataElement.Parent.Parent["@Status"].Equals("Sealed"))
                    {
                        // 如果是自己的贴
                        EventManager eventManager
                            = new EventManager();

                        IDataElement eventDE
                            = eventManager.GetElement(
                            DataElement.Parent.Parent
                            ["@EventId"]);
                        Guid userId = FAQContext.Current.User.AccountId;
                        if (eventDE["AccountId"].Equals(userId))
                        {
                            ShowContent(NamedContent.Normal);
                        }
                    }
                }
            }
        }
    }
}
